/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package cse.om.data;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author hungl_000
 */
@Entity
@Table(name = "Profile", catalog = "Facebook", schema = "dbo")
@NamedQueries({
	@NamedQuery(name = "Profile.findAll", query = "SELECT p FROM Profile p"),
	@NamedQuery(name = "Profile.findById", query = "SELECT p FROM Profile p WHERE p.id = :id"),
	@NamedQuery(name = "Profile.findByName", query = "SELECT p FROM Profile p WHERE p.name = :name"),
	@NamedQuery(name = "Profile.findByUserName", query = "SELECT p FROM Profile p WHERE p.userName = :userName"),
	@NamedQuery(name = "Profile.findByFirstName", query = "SELECT p FROM Profile p WHERE p.firstName = :firstName"),
	@NamedQuery(name = "Profile.findByLastName", query = "SELECT p FROM Profile p WHERE p.lastName = :lastName"),
	@NamedQuery(name = "Profile.findByLink", query = "SELECT p FROM Profile p WHERE p.link = :link"),
	@NamedQuery(name = "Profile.findByGender", query = "SELECT p FROM Profile p WHERE p.gender = :gender")})
public class Profile implements Serializable {
	@Transient
	private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
	private static final long serialVersionUID = 1L;
	@Id
    @Basic(optional = false)
    @Column(name = "Id")
	private Long id;
	@Column(name = "Name")
	private String name;
	@Column(name = "UserName")
	private String userName;
	@Column(name = "FirstName")
	private String firstName;
	@Column(name = "LastName")
	private String lastName;
	@Column(name = "Link")
	private String link;
	@Column(name = "Gender")
	private String gender;

	public Profile() {
	}

	public Profile(Long id) {
		this.id = id;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		Long oldId = this.id;
		this.id = id;
		changeSupport.firePropertyChange("id", oldId, id);
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		String oldName = this.name;
		this.name = name;
		changeSupport.firePropertyChange("name", oldName, name);
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		String oldUserName = this.userName;
		this.userName = userName;
		changeSupport.firePropertyChange("userName", oldUserName, userName);
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		String oldFirstName = this.firstName;
		this.firstName = firstName;
		changeSupport.firePropertyChange("firstName", oldFirstName, firstName);
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		String oldLastName = this.lastName;
		this.lastName = lastName;
		changeSupport.firePropertyChange("lastName", oldLastName, lastName);
	}

	public String getLink() {
		return link;
	}

	public void setLink(String link) {
		String oldLink = this.link;
		this.link = link;
		changeSupport.firePropertyChange("link", oldLink, link);
	}

	public String getGender() {
		return gender;
	}

	public void setGender(String gender) {
		String oldGender = this.gender;
		this.gender = gender;
		changeSupport.firePropertyChange("gender", oldGender, gender);
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (id != null ? id.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals(Object object) {
		// TODO: Warning - this method won't work in the case the id fields are not set
		if (!(object instanceof Profile)) {
			return false;
		}
		Profile other = (Profile) object;
		if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "cse.om.gui.Profile[ id=" + id + " ]";
	}

	public void addPropertyChangeListener(PropertyChangeListener listener) {
		changeSupport.addPropertyChangeListener(listener);
	}

	public void removePropertyChangeListener(PropertyChangeListener listener) {
		changeSupport.removePropertyChangeListener(listener);
	}
	
}
